﻿using System;
using System.Data;
using System.Collections;
using CE.Database;


/// <summary>
/// Summary description for TransactionDB
/// </summary>
namespace CE.CarInsurance
{
    public class TransactionDB
    {
        public Int64 Insert(Transaction transaction)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMNonGGTransactionInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@AgentId", transaction.AgentId);
            _sPara.Add("@AdminId", transaction.AdminId);
            _sPara.Add("@RefCEUserId", transaction.RefCEUserId);
            _sPara.Add("@CECarId", transaction.CECarId);
            _sPara.Add("@ProviderCompanyId", transaction.ProviderCompanyId);
            _sPara.Add("@QuoteRefNo", transaction.QuoteRefNo);
            _sPara.Add("@TransactionTypeId", transaction.TransactionTypeId);
            _sPara.Add("@Remarks", transaction.Remarks);
            _sPara.Add("@Status", transaction.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetTransaction(string QuoteRefNo, Int16 TransactionTypeId)
        {
            DataSet _dsCallStatus = null;
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "[sprocCXCRMNonGGTransactionSelectItemByQuoteRefNo]";

            SortedList _spara = new SortedList();
            _spara.Add("@QuoteRefNo", QuoteRefNo);
            _spara.Add("@TransactionTypeId", TransactionTypeId);

            using (DataSet _ds = _db.GetDataSet(_spName, _spara))
            {
                if (_ds != null && _ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0)
                {
                    _dsCallStatus = _ds;
                }
            }
            return _dsCallStatus;
        }

    }
}